package com.abo.yaas.view.widgets.fields;

import java.util.Arrays;
import java.util.List;

import com.abo.yaas.domain.AuctionState;
import com.vaadin.data.validator.NullValidator;
import com.vaadin.ui.Select;

@SuppressWarnings("serial")
public class StateCombo extends Select {
    public StateCombo() {
        super();
        final List<AuctionState> stateList = Arrays.asList(AuctionState
                .values());
        for (final AuctionState state : stateList) {
            addItem(state);
        }
        setWriteThrough(true);
        setNullSelectionAllowed(false);
        setImmediate(true);
        setWidth("100%");
        setRequired(true);
        addValidator(new NullValidator("You must chose category!", false));
    }

    public StateCombo(String caption) {
        this();
        setCaption(caption);
    }
}
